using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class huqiang_Data_DataLoader_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            FieldInfo field;
            Type[] args;
            Type type = typeof(huqiang.Data.DataLoader);
            args = new Type[]{typeof(huqiang.Data.FakeStruct), typeof(UnityEngine.Component), typeof(huqiang.Data.FakeStruct)};
            method = type.GetMethod("LoadToComponent", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, LoadToComponent_0);
            args = new Type[]{typeof(huqiang.Data.FakeStruct), typeof(UnityEngine.Component), typeof(huqiang.Data.Initializer)};
            method = type.GetMethod("LoadToObject", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, LoadToObject_1);
            args = new Type[]{typeof(UnityEngine.Component), typeof(huqiang.Data.DataBuffer)};
            method = type.GetMethod("LoadFromObject", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, LoadFromObject_2);

            field = type.GetField("gameobjectBuffer", flag);
            app.RegisterCLRFieldGetter(field, get_gameobjectBuffer_0);
            app.RegisterCLRFieldSetter(field, set_gameobjectBuffer_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_gameobjectBuffer_0, AssignFromStack_gameobjectBuffer_0);
            field = type.GetField("initializer", flag);
            app.RegisterCLRFieldGetter(field, get_initializer_1);
            app.RegisterCLRFieldSetter(field, set_initializer_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_initializer_1, AssignFromStack_initializer_1);


            app.RegisterCLRCreateArrayInstance(type, s => new huqiang.Data.DataLoader[s]);


        }


        static StackObject* LoadToComponent_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Data.FakeStruct @main = (huqiang.Data.FakeStruct)typeof(huqiang.Data.FakeStruct).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.Component @com = (UnityEngine.Component)typeof(UnityEngine.Component).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            huqiang.Data.FakeStruct @fake = (huqiang.Data.FakeStruct)typeof(huqiang.Data.FakeStruct).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            huqiang.Data.DataLoader instance_of_this_method = (huqiang.Data.DataLoader)typeof(huqiang.Data.DataLoader).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.LoadToComponent(@fake, @com, @main);

            return __ret;
        }

        static StackObject* LoadToObject_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Data.Initializer @initializer = (huqiang.Data.Initializer)typeof(huqiang.Data.Initializer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.Component @com = (UnityEngine.Component)typeof(UnityEngine.Component).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            huqiang.Data.FakeStruct @fake = (huqiang.Data.FakeStruct)typeof(huqiang.Data.FakeStruct).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            huqiang.Data.DataLoader instance_of_this_method = (huqiang.Data.DataLoader)typeof(huqiang.Data.DataLoader).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.LoadToObject(@fake, @com, @initializer);

            return __ret;
        }

        static StackObject* LoadFromObject_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Data.DataBuffer @buffer = (huqiang.Data.DataBuffer)typeof(huqiang.Data.DataBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.Component @com = (UnityEngine.Component)typeof(UnityEngine.Component).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            huqiang.Data.DataLoader instance_of_this_method = (huqiang.Data.DataLoader)typeof(huqiang.Data.DataLoader).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.LoadFromObject(@com, @buffer);

            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


        static object get_gameobjectBuffer_0(ref object o)
        {
            return ((huqiang.Data.DataLoader)o).gameobjectBuffer;
        }

        static StackObject* CopyToStack_gameobjectBuffer_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Data.DataLoader)o).gameobjectBuffer;
            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_gameobjectBuffer_0(ref object o, object v)
        {
            ((huqiang.Data.DataLoader)o).gameobjectBuffer = (huqiang.Data.GameobjectBuffer)v;
        }

        static StackObject* AssignFromStack_gameobjectBuffer_0(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            huqiang.Data.GameobjectBuffer @gameobjectBuffer = (huqiang.Data.GameobjectBuffer)typeof(huqiang.Data.GameobjectBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((huqiang.Data.DataLoader)o).gameobjectBuffer = @gameobjectBuffer;
            return ptr_of_this_method;
        }

        static object get_initializer_1(ref object o)
        {
            return ((huqiang.Data.DataLoader)o).initializer;
        }

        static StackObject* CopyToStack_initializer_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Data.DataLoader)o).initializer;
            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_initializer_1(ref object o, object v)
        {
            ((huqiang.Data.DataLoader)o).initializer = (huqiang.Data.Initializer)v;
        }

        static StackObject* AssignFromStack_initializer_1(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            huqiang.Data.Initializer @initializer = (huqiang.Data.Initializer)typeof(huqiang.Data.Initializer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((huqiang.Data.DataLoader)o).initializer = @initializer;
            return ptr_of_this_method;
        }




    }
}
